﻿//创建时间: 2010-12-19
//创建作者: 李 城
//功能说明: 用户操作 映射
//最后修改: 2011-1-24
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Reflection;

using TRPOP.Common;
using TRPOP.CMS.Model;
using TRPOP.CMS.DALFactory;
using TRPOP.ComSqlDAL;

namespace TRPOP.CMS.Plugin
{
    /// <summary>
    /// 数据库底层操作通用类 Builder
    /// </summary>
    public class ICommonDALAccess
    {
        const string mstrpath = "TRPOP.ComSqlDAL";
        const string mstrclassName = "TRPOP.ComSqlDAL.CommonDAL";
        public static ICommonDAL GetInstance()
        {
            /*
             * 
             *  之前的实现方式 
             *  2011.07.07 lcheng
             * 
            ICache oICache = ICacheAccess.GetInstance();
            if (oICache.IsExist(CacheKeys.Sys_ICommonDALAccess) == false)
            {
                ICommonDAL oICommonDAL = (ICommonDAL)Assembly.Load(mstrpath).CreateInstance(mstrclassName);
                oICache.Save(CacheKeys.Sys_ICommonDALAccess,
                               oICommonDAL,
                               SYSConfig.CahceSeconds);
                return oICommonDAL;
            }
            return (ICommonDAL)oICache.Read(CacheKeys.Sys_ICommonDALAccess);
            */
            return CacheHelper.GetByICache<ICommonDAL>(
                    CacheKeys.Sys_ICommonDALAccess,
                    SYSConfig.SystemVar_CahceSeconds,
                    ICacheAccess.GetInstance(),
                    () =>
                    {
                        return (ICommonDAL)Assembly.Load(mstrpath).CreateInstance(mstrclassName);
                    }
            );
        }
    }
}
